package com.bear.cmcc.NetTestHTTP.service;

import com.bear.cmcc.NetTestHTTP.constant.FtpConstant;
import com.bear.cmcc.NetTestHTTP.util.FtpUtil;

import android.content.Context;

import java.io.File;

/**
 * NetSpeedInfoService私用的工具类。
 * @author suchangjun
 *
 */
public class NetSpeedInfoServiceUtil {

    /**
     * 开始进行福建小区排名数据下载。
     * 
     * @param context
     * @return
     */
    public static boolean beginDownFjNetWorkFile(Context context) {
        boolean isSuccess = false;
        try {
            File file = null;
    
            String[] remoteFiles = FtpConstant.ALL_FJ_Files;
    
            for (String filePath : remoteFiles) {
                file = new File(context.getFilesDir() + FtpConstant.FJ_FLOADER + filePath);
                if (file.exists()) {
                    file.delete();
                }
            }
    
            isSuccess = FtpUtil.downloadFileByFjFTP(context, remoteFiles);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return isSuccess;
    }

    /**
     * 开始进行全国数据下载。
     * 
     * @param context
     * @return
     */
    public static boolean beginDownCountryNetWorkFile(Context context) {
        boolean isSuccess = false;
        try {
            File file = null;
    
            String[] remoteFiles = FtpConstant.ALL_PRI_Files;
    
            for (String filePath : remoteFiles) {
                file = new File(context.getFilesDir() + "/" + filePath);
                if (file.exists()) {
                    file.delete();
                }
            }
    
            isSuccess = FtpUtil.downloadFileByComFTP(context, remoteFiles);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return isSuccess;
    }

}
